//
//  File.swift
//  weibo
//
//  Created by chenhongen on 15/10/20.
//  Copyright © 2015年 陈弘根. All rights reserved.
//

import UIKit

extension UIButton
{
    convenience init(imageName: String, backImageName: String)
    {
        self.init()
        
        // 1.设置背景图片
        setBackgroundImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: imageName + "highlighted"), forState: UIControlState.Highlighted)
        
        // 2.设置普通图片
        setImage(UIImage(named:backImageName), forState: UIControlState.Normal)
        setImage(UIImage(named: backImageName + "highlighted"), forState: UIControlState.Highlighted)
        
        sizeToFit()
    }
    
    convenience init(title: String, color: UIColor,  backImageName: String)
    {
        self.init()
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(color, forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: backImageName), forState: UIControlState.Normal)
    }


}

